<!DOCTYPE html>
<html lang="en">
<head>
	<title>创建巡检单</title>
	<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, maximum-scale=1, user-scalable=no" charset="UTF-8">
	<link rel="stylesheet" href="android_asset://css/style.css"/>
    <link rel="stylesheet" href="android_asset://css/font.css"/>
</head>
<body>
	<div class="inspection" >
		<form id="form" class="form-horizontal" action="/tickets/createInspectionTicket">
		<input type="hidden" id="projectText" value="{{projectText}}">
			<div class="form-group clearfix martop">
		  		<div class="content bortno">
			    	<label  class="left control-label">项目名称</label>
			    	<div class="right">
				    	<div class="input-group">
							<input type="text" required id="projectSelect" class="form-control" readonly="readonly"  placeholder="请选择项目名称"  value="" maxlength="70"><span class="icon-rightarrow"></span>
				     		<input type="hidden" id="project" name="project" >
						</div>
				    </div>				    
				</div>
		  	</div>
		  	<div class="form-group clearfix">
		  		<div class="content">
			    	<label  class="left control-label">客户名称</label>
			    	<div class="right">
				    	<input type="text" required class="form-control"  placeholder="请填写客户名称" id="customerName" name="customerName" value="" maxlength="70">
				    </div>
				</div>
		  	</div>
		  	<div class="form-group clearfix">
		  		<div class="content">
			    	<label  class="left control-label">客户电话</label>
			    	<div class="right">
				    	<input type="text" required class="form-control"  placeholder="请填写客户电话" id="customerphone" name="customerphone" value="" maxlength="18">
				    </div>
				</div>
		  	</div>
  		  	<div class="form-group clearfix">
		  		<div class="content">
			    	<label  class="left control-label">门店编号</label>
			    	<div class="right">
				    	<input type="text" required class="form-control"  placeholder="请填写门店编号" id="ChrUserID" name="ChrUserID" value="" maxlength="10">
				    </div>
				</div>
		  	</div>
		  	<div class="form-group clearfix">
		  		<div class="content">
			    	<label  class="left control-label">门店地址</label>
			    	<div class="right">
				    	<input type="text" required class="form-control"  placeholder="请填写门店地址" id="customeraddress" name="customeraddress" value="" maxlength="70">
				    </div>
				</div>
		  	</div>
		  	<div class="form-group clearfix">
		  		<div class="content">
			    	<label  class="left control-label">巡检内容</label>
			    	<div class="right">
				    	<input type="text" required class="form-control"  placeholder="请填写巡检内容" id="title" name="title" value="" maxlength="70">
				    </div>
				</div>
		  	</div>
		</form>
		<div class="confirm_import" style="position:fixed;">
			<button type="button" class="but"><a href="javascript:void(0);">确认</a></button>
		</div>
	</div>
</body>
<script src="android_asset://jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="android_asset://jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<script src="android_asset://bridge.js" type="text/javascript"></script>
<script src="android_asset://android.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
	  $('button.but').on('keydown touchstart', function () {
		  $(this).css("background", '#216cb9');
	  });
	  $('button.but').on('keyup touchend', function () {
	      $(this).css("background", '#3e8ddd');
	  });
});
$(function(){
	//选择项目名称
	$("#projectSelect").click(function(){
		var projectText = $("#projectText").val();
		  ticketProject(this,'#project',projectText);
	});
    
	//表单提交及校验   
	$(".confirm_import button").click(function(){
		var flag=false;
		var project = $("#project").val();
		var customerName = $("#customerName").val();
		var customerPhone = $("#customerphone").val();
		var customeraddress = $("#customeraddress").val();
		var title = $("#form :input[name='title']").val();
		$("#form [required]").each(function(){
			  if($.trim($(this).val())==''){
				  msAndroid.toast($(this).attr("placeholder"));
				  flag=true;
				  return false;
			  }
		});
		if(flag){
			 return;
		}
		var regTel = /^([0-9]|[-])+$/.test(customerPhone);
		if(!regTel){
		 	msAndroid.toast("请输入正确的联系电话");
		 return ;
		};
		//校验巡检内容
		if(title.length<10|title.length>70){
			 msAndroid.toast("请输入10~70字的巡检内容");
			 return;
		}
		//表单提交
		var url=$("#form").attr("action");
		var formJson=msAndroid.ticketVO("#form");
		var btn = this;
		var backUrl="/tickets/{ticketid}/uploadDevice";
		msAndroid.postCreateTicket(url,formJson,'post',backUrl,function(){
			btn.disabled = false;
		});
		//禁止页面二次提交
	 	btn.disabled = true;
	}); 
});
</script>

</html>